import { observable, action } from 'mobx'
import * as api from 'lib/constants/api'
import { post } from 'lib/net'
import Toast from 'components/toast'
import Load from 'components/load'

// class AddressModel {
//   constructor (data) {
//     if (data) {
//     }
//   }
// }

export default class CheckCommissionVM {
  constructor (props) {
    this.props = props
    this.PageInitialization()
  }

  // 佣金页面详情
  @observable commissionDetail = {}

  // 跳转到已结算页面
  @action handleToSettlement = () => {
    this.props.history.push('/settlementRecord')
  }

  // 跳转到待结算佣金（时长服务）
  @action handleToBalance = () => {
    this.props.history.push('/noneComplete')
  }

  // 跳转到客户投诉已扣除合计
  @action handleToTotal = () => {
    this.props.history.push('/complaintRecord')
  }

  // 跳转到佣金结算规则
  @action handleToCommissionRule = () => {
    this.props.history.push('/commissionRule')
  }

  @action PageInitialization = async () => {
    Load.loading(1, '加载中')
    const UserId = window.localStorage.getItem('UserId')
    let response = await post(api.GETAPPSETTLE, { WZId: UserId })
    if (response.Success) {
      Load.loading(2, '加载完成')
      this.commissionDetail = response.Value
    } else {
      Toast.fail(response.Message)
    }
  }
}
